﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterAdmin.master" AutoEventWireup="true" CodeBehind="Calculate_Salary.aspx.cs" Inherits="UdrinkWater_Project.Admin.Calculate_Salary" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
     <script type="text/javascript">
    // <![CDATA[
         function ShowLoginWindow() {
             pc_Salary.Show();
         }
    // ]]> 
    </script>
    <dx:ASPxRoundPanel ID="ASPxRoundPanel1" runat="server" 
        HeaderText="รายงานเงินเดือนพนักงาน" Width="100%">
        <HeaderStyle Font-Size="Medium" HorizontalAlign="Left" />
        <PanelCollection>
<dx:PanelContent runat="server" SupportsDisabledAttribute="True">
    <div>
        
        <table style="width: 100%">
            <tr>
                <td align="right" style="width: 922px">
                    &nbsp;</td>
                <td align="right">
                    <table style="width: 100%">
                        <tr>
                            <td>
                                <dx:ASPxButton ID="bt_CalculateAndExport" runat="server" 
                                    OnClick="bt_CalculateAndExport_Click" Text="คำนวณเงินเดือนและพิมพ์สลิป" 
                                    Width="120px" AutoPostBack="False" UseSubmitBehavior="False">
                                </dx:ASPxButton>
                            </td>
                            <td>
                                <dx:ASPxButton ID="bt_ExportSlipSalary" runat="server" 
                                    Text="พิมพ์รายงานเงินเดือนพนักงาน" Width="120px">
                                </dx:ASPxButton>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        <dx:ASPxPivotGrid ID="PivotGrid_Salary" runat="server" ClientIDMode="AutoID" 
            DataSourceID="SqlData_Salary" Width="100%" TotalsVisibility="CustomTotals">
            <Fields>
                <dx:PivotGridField ID="fieldEmployee" Area="RowArea" AreaIndex="1" 
                    FieldName="Employee" Caption="พนักงาน">
                </dx:PivotGridField>
                <dx:PivotGridField ID="fieldSalary" AreaIndex="0" 
                    FieldName="Salary">
                </dx:PivotGridField>
                <dx:PivotGridField ID="fieldSalaryStart" Area="RowArea" AreaIndex="0" 
                    FieldName="Salary_Start" GroupInterval="DateMonth" 
                    UnboundFieldName="fieldSalaryStart" Caption="ประจำเดือน">
                </dx:PivotGridField>
                <dx:PivotGridField ID="fieldSalaryEnd" Area="ColumnArea" AreaIndex="0" 
                    FieldName="Salary_End" GroupInterval="DateYear" 
                    UnboundFieldName="fieldSalaryEnd" Caption="ประจำปี">
                </dx:PivotGridField>
                <dx:PivotGridField ID="fieldSalaryOT" Area="DataArea" AreaIndex="0" 
                    FieldName="Salary_OT" Caption="เงินล่วงเวลา">
                    <CellStyle HorizontalAlign="Center">
                        <Paddings PaddingLeft="40px" PaddingRight="40px" />
                    </CellStyle>
                </dx:PivotGridField>
                <dx:PivotGridField ID="fieldSalaryAbsence" Area="DataArea" AreaIndex="2" 
                    FieldName="Salary_Absence" Caption="ค่าปรับขาดงาน">
                    <CellStyle HorizontalAlign="Center">
                        <Paddings PaddingLeft="40px" PaddingRight="40px" />
                    </CellStyle>
                </dx:PivotGridField>
                <dx:PivotGridField ID="fieldSalaryWithDraw" Area="DataArea" AreaIndex="3" 
                    FieldName="Salary_WithDraw" Caption="เบิกล่วงหน้า">
                    <CellStyle HorizontalAlign="Center">
                        <Paddings PaddingLeft="40px" PaddingRight="40px" />
                    </CellStyle>
                </dx:PivotGridField>
                <dx:PivotGridField ID="fieldSalaryOther" Area="DataArea" AreaIndex="4" 
                    FieldName="Salary_Other" Caption="อื่นๆ">
                    <CellStyle HorizontalAlign="Center">
                        <Paddings PaddingLeft="40px" PaddingRight="40px" />
                    </CellStyle>
                </dx:PivotGridField>
                <dx:PivotGridField ID="fieldSalaryCommission" Area="DataArea" AreaIndex="1" 
                    FieldName="Salary_Commission" Caption="ค่าคอมมิชชั่น">
                    <CellStyle HorizontalAlign="Center">
                        <Paddings PaddingLeft="40px" PaddingRight="40px" />
                    </CellStyle>
                </dx:PivotGridField>
                <dx:PivotGridField ID="fieldTotal" Area="DataArea" AreaIndex="5" 
                    Caption="เงินเดือนสุทธิ" FieldName="Total">
                    <CellStyle HorizontalAlign="Center">
                        <Paddings PaddingLeft="40px" />
                    </CellStyle>
                </dx:PivotGridField>
            </Fields>
            <OptionsView ShowDataHeaders="False" ShowFilterHeaders="False" />
            <OptionsCustomization AllowSortBySummary="False" />
            <OptionsPager NumericButtonCount="20" Position="Bottom" RowsPerPage="50">
            </OptionsPager>
            <OptionsData AutoExpandGroups="True" />
            <OptionsFilter NativeCheckBoxes="False" />
            <StylesPrint Cell-BackColor2="" Cell-GradientMode="Horizontal" 
                CustomTotalCell-BackColor2="" CustomTotalCell-GradientMode="Horizontal" 
                FieldHeader-BackColor2="" FieldHeader-GradientMode="Horizontal" 
                FieldValue-BackColor2="" FieldValue-GradientMode="Horizontal" 
                FieldValueGrandTotal-BackColor2="" 
                FieldValueGrandTotal-GradientMode="Horizontal" FieldValueTotal-BackColor2="" 
                FieldValueTotal-GradientMode="Horizontal" GrandTotalCell-BackColor2="" 
                GrandTotalCell-GradientMode="Horizontal" Lines-BackColor2="" 
                Lines-GradientMode="Horizontal" TotalCell-BackColor2="" 
                TotalCell-GradientMode="Horizontal" />
        </dx:ASPxPivotGrid>
        <asp:SqlDataSource ID="SqlData_Salary" runat="server" 
            ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
            SelectCommand="SELECT TB_Employee.ID_Card + '  ' + TB_Employee.Firstname AS Employee, 
TB_Employee.Salary, TB_Salary.Salary_Start, TB_Salary.Salary_End, TB_Salary.Salary_OT, TB_Salary.Salary_Absence, 
TB_Salary.Salary_WithDraw, TB_Salary.Salary_Other, TB_Salary.Salary_Commission,
((TB_Employee.Salary+TB_Salary.Salary_OT+TB_Salary.Salary_Commission)-(TB_Salary.Salary_Absence+TB_Salary.Salary_WithDraw+TB_Salary.Salary_Other)) AS Total
FROM TB_Employee INNER JOIN TB_Salary ON TB_Employee.ID_Card = TB_Salary.Employee_ID">
        </asp:SqlDataSource>
        
        <dx:ASPxPopupControl ID="pc_Salary" runat="server" AllowDragging="True" 
            ClientInstanceName="pc_Salary" CloseAction="CloseButton" EnableViewState="False" 
            Font-Size="Medium" HeaderText="พิมพ์สลิปเงินเดือน" Modal="True" 
            PopupAnimationType="None" PopupHorizontalAlign="WindowCenter" 
            PopupVerticalAlign="WindowCenter" Width="379px">
            <ContentStyle>
                <Paddings PaddingBottom="5px" />
            </ContentStyle>
            <ContentCollection>
                <dx:PopupControlContentControl runat="server" SupportsDisabledAttribute="True">
                    <dx:ASPxPanel ID="Panel2" runat="server" DefaultButton="btOK">
                        <PanelCollection>
                            <dx:PanelContent runat="server" SupportsDisabledAttribute="True">
                                <table>
                                    <tr>
                                        <td rowspan="3">
                                            <div class="pcmSideSpacer">
                                            </div>
                                        </td>
                                        <td align="right" class="pcmCellCaption" style="font-size: medium">
                                            ประจำปี :</td>
                                        <td class="pcmCellText">
                                            <dx:ASPxComboBox ID="Cb_Year" runat="server">
                                                <Items>
                                <dx:ListEditItem Selected="True" Text="2557" Value="2557" />
                                <dx:ListEditItem Text="2558" Value="2558" />
                                <dx:ListEditItem Text="2559" Value="2559" />
                                <dx:ListEditItem Text="2560" Value="2560" />
                                <dx:ListEditItem Text="2561" Value="2561" />
                                <dx:ListEditItem Text="2562" Value="2562" />
                                <dx:ListEditItem Text="2563" Value="2563" />
                                <dx:ListEditItem Text="2564" Value="2564" />
                                <dx:ListEditItem Text="2565" Value="2565" />
                                <dx:ListEditItem Text="2566" Value="2566" />
                                <dx:ListEditItem Text="2567" Value="2567" />
                                <dx:ListEditItem Text="2568" Value="2568" />
                                <dx:ListEditItem Text="2569" Value="2569" />
                                <dx:ListEditItem Text="2570" Value="2570" />
                            </Items>
                                            </dx:ASPxComboBox>
                                        </td>
                                        <td rowspan="3">
                                            <div class="pcmSideSpacer">
                                            </div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="right" class="pcmCellCaption" style="font-size: medium">
                                            ประจำเดือน :</td>
                                        <td class="pcmCellText">
                                            <dx:ASPxComboBox ID="Cb_Month" runat="server">
                                                 <Items>
                            <dx:ListEditItem Selected="True" Text="มกราคม" Value="01" />
                            <dx:ListEditItem Text="กุมภาพันธ์" Value="02" />
                            <dx:ListEditItem Text="มีนาคม" Value="03" />
                            <dx:ListEditItem Text="เมษายน" Value="04" />
                            <dx:ListEditItem Text="พฤษภาคม" Value="05" />
                            <dx:ListEditItem Text="มิถุนายน" Value="06" />
                            <dx:ListEditItem Text="กรกฎาคม" Value="07" />
                            <dx:ListEditItem Text="สิงหาคม" Value="08" />
                            <dx:ListEditItem Text="กันยายน" Value="09" />
                            <dx:ListEditItem Text="ตุลาคม" Value="10" />
                            <dx:ListEditItem Text="พฤศจิกายน" Value="11" />
                            <dx:ListEditItem Text="ธันวาคม" Value="12" />
                        </Items>
                                            </dx:ASPxComboBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                        </td>
                                        <td class="pcmCheckBox">
                                            <table style="width: 100%">
                                                <tr>
                                                    <td>
                                                        <dx:ASPxButton ID="btOK" runat="server" AutoPostBack="False" Font-Size="Medium" 
                                                            style="float: left; margin-right: 8px" Text="ตกลง" 
                                                            Width="80px" OnClick="btOK_Click">
                                                            <ClientSideEvents Click="function(s, e) { if(ASPxClientEdit.ValidateGroup('entryGroup')) pc_Salary.Hide(); }" />
                                                        </dx:ASPxButton>
                                                    </td>
                                                    <td>
                                                        <dx:ASPxButton ID="btCancel" runat="server" AutoPostBack="False" 
                                                            Font-Size="Medium" style="float: left; margin-right: 8px" Text="ยกเลิก" 
                                                            Width="80px">
                                                            <ClientSideEvents Click="function(s, e) { pc_Salary.Hide(); }" />
                                                        </dx:ASPxButton>
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                </table>
                            </dx:PanelContent>
                        </PanelCollection>
                    </dx:ASPxPanel>
                    <div>
                        &nbsp;</div>
                </dx:PopupControlContentControl>
            </ContentCollection>
        </dx:ASPxPopupControl>
        
    </div>
            </dx:PanelContent>
</PanelCollection>
    </dx:ASPxRoundPanel>
</asp:Content>
